<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<meta name="description" content="对网页的一段概括性描述" />
<meta name="keywords" content="关键字1,关键字2,关键字3..." />
<meta name="renderer" content="webkit">
<title>Hiring-</title>
 <%@ include file="/WEB-INF/view/common/import.jsp"%>
<style>
.allposition {
	width: 1000px;
	margin: 0 auto;
	margin-top: 20px;
}

.aa {
	width: 1000px;
	margin: 0 auto;
	margin-top: 20px;
}

.companyname {
	color: white;
	font-size: 20px;
	font-weight: bold;
}

.select {
	height: 34px;
	border: 1px solid #ccc;
}

	.fontColor{
	color: white;
	}
</style>
</head>
<body>
	<div>
		<div class="breadcrumb" style="background-color: black;">
			<a href="#" class="fontColor">主页|</a>
			<a href="<%=request.getContextPath()%>/TalentServlet?command=toLoginUi" class="fontColor">求职者登录|</a>
			<a href="<%=request.getContextPath()%>/TalentServlet?command=toRegisterUi" class="fontColor">求职者注册|</a>
			<a id="companyLogin" href="<%=request.getContextPath()%>/CompanyServlet?command=goCompanyLoginUI" class="fontColor">公司登录|</a>
			<a href="<%=request.getContextPath()%>/CompanyServlet?command=goCompanyRegisterUI" class="fontColor">公司注册</a>
			<a id="personal" hidden="hidden" href="<%=request.getContextPath()%>/CompanyServlet?command=goCompanyMain&code=${sessionScope.companyEntity.code}&password=${sessionScope.companyEntity.password}" class="fontColor">|企业后台</a>
			
		</div>
		
		<div style="padding-top: 9px; margin-left: 1010px">
			<c:if test="${! empty companyEntity }">
				<span style="color: green">欢迎您&nbsp;!&nbsp;${sessionScope.companyEntity.name }</span>
				<script>
				document.getElementById("personal").removeAttribute("hidden");
				document.getElementById('companyLogin').hidden='hidden';
		</script>
			</c:if>
			<c:if test="${empty companyEntity }">
				<span style="color: red">您还没有登录，请登录！</span>
			</c:if>
		</div>
	</div>
	<c:forEach items="${pageModel.list}" var="homepageAllPositionList"
		varStatus="v">
		<div class="panel panel-primary allposition">
			<div class="panel-heading">
				<a href="<%=request.getContextPath()%>/CompanyServlet?command=homepageCompanyDateilInfo&companyId=${homepageAllPositionList.company$id }">
				<kbd>${v.count + (pageModel.pageNo -1)* pageModel.pageSize}</kbd>&nbsp;&nbsp;&nbsp;<span class="companyname">${homepageAllPositionList.companyName }</span></a>
				&nbsp;&nbsp;&nbsp;${homepageAllPositionList.companySlogan }
			</div>
			<div class="panel-body">
				<a href="<%=request.getContextPath()%>/PositionServlet?command=homepagePositionDateilInfo&positionId=${homepageAllPositionList.id }">
				${homepageAllPositionList.name }</a>&nbsp;&nbsp;￥${homepageAllPositionList.salary1 }~${homepageAllPositionList.salary2 }
				&nbsp;&nbsp; ${homepageAllPositionList.companyAddress } &nbsp;&nbsp;${fn:substring(homepageAllPositionList.releaseTime,0,19) }
			</div>
		</div>
	</c:forEach>
	<!--
		<div class="pull-right aa">
		<button type="button" class="btn btn-default"
			onclick="location='<%=request.getContextPath()%>/PositionServlet?command=selectAllPosition&pageNo=${pageModel.first }'"
			<c:if test="${pageModel.pageNo == pageModel.first }">disabled="disabled"</c:if>>首页</button>
		<button type="button" class="btn btn-default"
			onclick="location='<%=request.getContextPath()%>/PositionServlet?command=selectAllPosition&pageNo=${pageModel.pre }'"
			<c:if test="${pageModel.pageNo == pageModel.first }">disabled="disabled"</c:if>>上一页</button>
		
		<select onchange="go(this)" class="select">
			<script>
		        			var totalPage = '${pageModel.totalPage }';
		        			var pageNo = '${pageModel.pageNo}'
		        			for (var i = 1; i <= totalPage; i++) {
		        				if (i == pageNo) {
		        				   document.write('<option value="'+ i +'" selected>第' + i +'页</option>');
		        				} else {
		        				   document.write('<option value="'+ i +'">第' + i +'页</option>');	
		        				}
		        			}
		        		</script>
		</select>
		 <button type="button" class="btn btn-default"
			onclick="location='<%=request.getContextPath()%>/PositionServlet?command=selectAllPosition&pageNo=${pageModel.next }'"
			<c:if test="${pageModel.pageNo == pageModel.last }">disabled="disabled"</c:if>>下一页</button>
		<button type="button" class="btn btn-default"
			onclick="location='<%=request.getContextPath()%>/PositionServlet?command=selectAllPosition&pageNo=${pageModel.last }'"
			<c:if test="${pageModel.pageNo == pageModel.last }">disabled="disabled"</c:if>>尾页</button>
		&nbsp;&nbsp;&nbsp;&nbsp; 当前第${pageModel.pageNo }页，
		显示${(pageModel.pageNo - 1) * pageModel.pageSize + 1}到第${(pageModel.pageNo - 1) * pageModel.pageSize + pageModel.pageSize}，共${pageModel.totalPage }页 
	</div>
	-->
		<script>
    		/**
    		 * 指定跳转到第几页
    		 */
    		function go(obj) {
    			location='<%=request.getContextPath()%>/PositionServlet?command=selectAllPosition&pageNo='
					+ obj.value;
    		}
    	</script>
    		<script>
    		var footerSmall = document.querySelector('.footer-small');
			// 滚动条总共高度(scrollHeight) = 滚动过的高度(scrollTop) + 屏幕的可见高度(windowHeight)
			var scrollHeight = document.body.scrollHeight || document.documentElement.scrollHeight;
			var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
			var flag = true;
			int pageNo=1;
			int a = pageNo;
			window.onscroll = function() {
				var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
				if(scrollHeight - (scrollTop + windowHeight) <= 50 && flag) {
					flag = false;
					$.get('<%=request.getContextPath()%>/PositionServlet?command=AjaxAddPositon&pageNo='+a+'&time=' + new Date().getTime(), function(datas) {
						var html = [];
						for (var i = 0; i < datas.length; i++) {
							html.push('<div class="panel-heading">');
							html.push('  <div class="panel-heading">')
							html.push('<a href="<%=request.getContextPath()%>/CompanyServlet?command=homepageCompanyDateilInfo&companyId=${homepageAllPositionList.company$id }"><kbd>'+i+'</kbd>&nbsp;&nbsp;&nbsp;<span class="companyname">'+datas[i].companyName+'</span></a>&nbsp;&nbsp;&nbsp;'+datas[i].companySlogan);
							html.push('  </div>');
							html.push('  <div class="panel-body">');
							html.push('    <a href="<%=request.getContextPath()%>/PositionServlet?command=homepagePositionDateilInfo&positionId=${homepageAllPositionList.id }">'+datas[i].name+'</a>&nbsp;&nbsp;￥$'+datas[i].salary1 +'~'+datas[i].salary2 +'&nbsp;&nbsp;'+ datas[i].companyAddress  +'&nbsp;&nbsp;'+datas[i].releaseTime);
							html.push('  </div>');
							html.push('</div>');
						}
						$('.allposition').append(html.join(''));
						scrollHeight = document.body.scrollHeight || document.documentElement.scrollHeight;
						flag = true;
						pageNo+=1;
					}, 'json')
				} 
			}
			</script>
	
	
</body>
</html>

